package com.hung.triple.loadbalancer;

import java.util.List;

/**
 * @author Hung
 * @date 2022/9/24 23:22
 */
public class RoundRobinLoadBalancer<T> implements AbstractLoadBalancer<T> {

    private int index = 0;

    @Override
    public T select(List<T> instances) {
        if (index >= instances.size()) {
            index %= instances.size();
        }
        return instances.get(index++);
    }
}
